/**
  ******************************************************************************
  * @file 
  * @brief 
  * @author taoye
  * @version V1.0.0
  * @date 2021/01/01
  ******************************************************************************
  */
#ifndef _DRV_I2C_SOFT_H
#define _DRV_I2C_SOFT_H 

#include "drv_include.h"
#include "drv_f4_gpio.h"

/* private config -----------------------------------------------------------*/
typedef struct
{
    drv_gpio_t  sda;
    drv_gpio_t  scl;
    uint8_t     sda_num;
}i2c_private_t;

/* Public defines -----------------------------------------------------------*/
typedef struct drv_i2c     drv_i2c_t;

/* Public enum    -----------------------------------------------------------*/
typedef enum
{
    I2C_SPEED_HIGH,
    I2C_SPEED_MEDIUM,
    I2C_SPEED_SLOW,
}i2c_speed_e;

typedef enum
{
    I2C_WIDTH_BYTE,
    I2C_WIDTH_HALFWORLD,
}i2c_addr_width_e;

typedef enum
{
    I2C_TIMEOUT_STOP,
    I2C_TIMEOUT_CONTINUE,
}i2c_acktimeout_e;


/* Public Struct  -----------------------------------------------------------*/

struct  drv_i2c
{
    /* ***************Public Parameter  *************** */
    const char *            PIN_SDA;
    const char *            PIN_SCL;

    i2c_speed_e             SPEED;
    i2c_addr_width_e        WIDTH;
    i2c_acktimeout_e        ACK_TIMEOUT;
    uint32_t                ACK_WAIT_US;
	bool                    SAMPLE_DELAY;

    /* ***************Public Method     *************** */
    int ( *Check )  ( drv_i2c_t *, uint8_t );
    int ( *Write )  ( drv_i2c_t *, uint8_t, uint16_t, uint8_t *, uint32_t );
    int ( *Read  )  ( drv_i2c_t *, uint8_t, uint16_t, uint8_t *, uint32_t );

    /* ***************Private Attributes*************** */
    i2c_private_t  private;
};


/* Public Variable  ---------------------------------------------------------*/
//Pointer

//Array

//Const


/* Pubilc function prototypes -----------------------------------------------*/


int Drv_I2c_Init(drv_i2c_t * i2c);
	
#endif

